package com.ruoyi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VehicleOperationLogs;
import com.ruoyi.system.service.IVehicleOperationLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆操作日志Controller
 * 
 * @author whut
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/system/logs")
public class VehicleOperationLogsController extends BaseController
{
    @Autowired
    private IVehicleOperationLogsService vehicleOperationLogsService;

    /**
     * 查询车辆操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:logs:list')")
    @GetMapping("/list")
    public TableDataInfo list(VehicleOperationLogs vehicleOperationLogs)
    {
        startPage();
        List<VehicleOperationLogs> list = vehicleOperationLogsService.selectVehicleOperationLogsList(vehicleOperationLogs);
        return getDataTable(list);
    }

    /**
     * 导出车辆操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:logs:export')")
    @Log(title = "车辆操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehicleOperationLogs vehicleOperationLogs)
    {
        List<VehicleOperationLogs> list = vehicleOperationLogsService.selectVehicleOperationLogsList(vehicleOperationLogs);
        ExcelUtil<VehicleOperationLogs> util = new ExcelUtil<VehicleOperationLogs>(VehicleOperationLogs.class);
        util.exportExcel(response, list, "车辆操作日志数据");
    }

    /**
     * 获取车辆操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:logs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        AjaxResult success = success(vehicleOperationLogsService.selectVehicleOperationLogsById(id));
        return success;
    }

    /**
     * 新增车辆操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:logs:add')")
    @Log(title = "车辆操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehicleOperationLogs vehicleOperationLogs)
    {
        return toAjax(vehicleOperationLogsService.insertVehicleOperationLogs(vehicleOperationLogs));
    }

    /**
     * 修改车辆操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:logs:edit')")
    @Log(title = "车辆操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleOperationLogs vehicleOperationLogs)
    {
        return toAjax(vehicleOperationLogsService.updateVehicleOperationLogs(vehicleOperationLogs));
    }

    /**
     * 删除车辆操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:logs:remove')")
    @Log(title = "车辆操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vehicleOperationLogsService.deleteVehicleOperationLogsByIds(ids));
    }
}
